package experiment11;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;
import javafx.stage.Stage;

public class No_4 extends Application {
    private int current_x=100;
    private int current_y=100;
    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) {
        Pane pane=new Pane();

        Scene scene=new Scene(pane,200,200);



        scene.setOnKeyPressed(event -> {

            if (event.getCode().equals(KeyCode.UP)){
                Line line=new Line(current_x,current_y,current_x,current_y-20);
                current_y=current_y-20;
                pane.getChildren().add(line);
            }
            if (event.getCode().equals(KeyCode.DOWN)){
                Line line=new Line(current_x,current_y,current_x,current_y+20);
                current_y=current_y+20;
                pane.getChildren().add(line);
            }
            if (event.getCode().equals(KeyCode.LEFT)){
                Line line=new Line(current_x,current_y,current_x-20,current_y);
                current_x=current_x-20;
                pane.getChildren().add(line);
            }
            if (event.getCode().equals(KeyCode.RIGHT)){
                Line line=new Line(current_x,current_y,current_x+20,current_y);
                current_x=current_x+20;
                pane.getChildren().add(line);
            }
        });

        primaryStage.setTitle("arrow line");
        primaryStage.setScene(scene);
        primaryStage.show();
    }
}
